package vistas;
import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ListadoClasificacion extends javax.swing.JFrame {
	private JPanel pnlCriteirio;
	private JLabel lblClasificacion;
	private JButton btnMostrar;
	private JTable tblListado;
	private JScrollPane spListado;
	private JButton btnLimpiar;
	private JComboBox cmbTipos;
	private JLabel lblMostrar;
	private JComboBox cmbClasificacion;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				ListadoClasificacion inst = new ListadoClasificacion();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public ListadoClasificacion() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				pnlCriteirio = new JPanel();
				getContentPane().add(pnlCriteirio);
				pnlCriteirio.setBounds(21, 22, 385, 139);
				pnlCriteirio.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED), "Criterio de busqueda", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION));
				pnlCriteirio.setLayout(null);
				{
					lblClasificacion = new JLabel();
					pnlCriteirio.add(lblClasificacion);
					lblClasificacion.setText("Clasificacion usada");
					lblClasificacion.setBounds(53, 27, 90, 14);
				}
				{
					ComboBoxModel cmbClasificacionModel = 
							new DefaultComboBoxModel(
									new String[] { "Item One", "Item Two" });
					cmbClasificacion = new JComboBox();
					pnlCriteirio.add(cmbClasificacion);
					cmbClasificacion.setModel(cmbClasificacionModel);
					cmbClasificacion.setBounds(167, 24, 152, 20);
				}
				{
					lblMostrar = new JLabel();
					pnlCriteirio.add(lblMostrar);
					lblMostrar.setText("Mostrar solo");
					lblMostrar.setBounds(53, 61, 103, 14);
				}
				{
					ComboBoxModel cmbTiposModel = 
							new DefaultComboBoxModel(
									new String[] { "Item One", "Item Two" });
					cmbTipos = new JComboBox();
					pnlCriteirio.add(cmbTipos);
					cmbTipos.setModel(cmbTiposModel);
					cmbTipos.setBounds(166, 58, 153, 20);
				}
				{
					btnMostrar = new JButton();
					pnlCriteirio.add(btnMostrar);
					btnMostrar.setText("Mostrar listado");
					btnMostrar.setBounds(53, 94, 113, 23);
				}
				{
					btnLimpiar = new JButton();
					pnlCriteirio.add(btnLimpiar);
					btnLimpiar.setText("Limpiar");
					btnLimpiar.setBounds(206, 94, 113, 23);
				}
			}
			{
				spListado = new JScrollPane();
				getContentPane().add(spListado);
				spListado.setBounds(25, 186, 375, 210);
				{
					TableModel tblListadoModel = 
							new DefaultTableModel(
									new String[] { "Codigo", "Nombre marca","Nombre generico",
											"Existencia"},0);
					tblListado = new JTable();
					spListado.setViewportView(tblListado);
					tblListado.setModel(tblListadoModel);
				}
			}
			pack();
			this.setSize(447, 480);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	/** Metodos SETTER*/
	
	public void setTipos (int item)
	{
		cmbTipos.setSelectedIndex(item);
	}
	
	public void setClasificacion (int item)
	{
		cmbClasificacion.setSelectedIndex(item);
	}

	/** Permite asignar una fila a la tabla*/
	public void agregarFila(Vector<String> datos)
	{
		DefaultTableModel dtm = (DefaultTableModel) tblListado.getModel();
		dtm.addRow(datos);
	}
	
	/**Metodos GETTER*/
	
	public int getTipos ()
	{
		return cmbTipos.getSelectedIndex();
	}
	
	
	public int getClasificacion ()
	{
		return cmbClasificacion.getSelectedIndex();
	}
	
	/** Permite limpiar la informacion mostrada por la tabla */
	public void limpiarFormulario(){
		TableModel tblListadoModel = 
				new DefaultTableModel(
						new String[] { "Codigo", "Nombre marca","Nombre generico",
								"Existencia"},0);
		tblListado.setModel(tblListadoModel);
		
	}
	
	
}
